//
//  YZMQuoteStyle.m
//  YZMicroStock
//
//  Created by wangminhong on 16/4/12.
//  Copyright © 2016年 cqjr. All rights reserved.
//

#import "YZMQuoteStyle.h"
#import <ColorUtils.h>

@implementation YZMQuoteStyle

+ (NSDictionary *)flashStyleDict{
    
    return @{
             FOCUS_LINE_COLOR_KEY:[UIColor colorWithString:@"F33737"],
             FLASH_CURRENT_LINE_COLOR_KEY:[UIColor colorWithString:@"1C81DB"],
             FLASH_TICK_LINE_COLOR_KEY:[UIColor colorWithString:@"F8F8F8"],
             FLASH_CURRENT_STRING_COLOR_KEY:[UIColor whiteColor],
             FLASH_TICK_STRING_COLOR_KEY:[UIColor colorWithString:@"999999"],
             FLASH_TICK_STRING_CENTER_COLOR_KEY:[UIColor colorWithString:@"666666"],
             };
}


+ (NSDictionary *)tradeTrendStyleDict{
    
    return @{
             FOCUS_LINE_COLOR_KEY: [UIColor colorWithString:@"F33737"],
             TREND_RISE_COLOR_KEY: [UIColor colorWithString:@"E34C4D"],
             TREND_FALL_COLOR_KEY: [UIColor colorWithString:@"01B28E"],
             TREND_TIME_COLOR: [UIColor colorWithString:@"999999"],
             TREND_CURRENT_LINE_COLOR_KEY:[UIColor colorWithString:@"1C81DB"],
//             TREND_CURRENT_LINE_COLOR_KEY:[UIColor colorWithString:@"2588D9"],
             TREDN_FILL_COLOR_KEY:[UIColor colorWithString:@"D6E6F57F"],
             CHAR_BOUND_COLOR_KEY: [UIColor colorWithString:@"F8F8F8"],
             TREND_LASTCOLOSELINE_COLOR_KEY:[UIColor colorWithString:@"E34C4D"],
             
             };
    
}

+ (NSDictionary *)trendStyleDict
{
    return @{
//             CHAR_BOUND_COLOR_KEY: [UIColor colorWithRed: 204.0/255.0 green:204.0/255.0 blue:204.0/255.0 alpha: 1.0],
             CHAR_BOUND_COLOR_KEY: [UIColor colorWithString:@"1C262F"],
             FOCUS_LINE_COLOR_KEY: [UIColor blueColor],
             FOCUS_BACK_COLOR_KEY: [UIColor grayColor],
             FOCUS_TEXT_COLOR_KEY: [UIColor blackColor],
             
             TREND_LASTCOLOSELINE_COLOR_KEY: [UIColor colorWithRed: 73/255.0 green: 167/255.0 blue: 246/255.0 alpha: 1.0],
             TREND_TIME_COLOR: [YZMAppStyle colorForMainTextColor],
             TREND_RISE_COLOR_KEY:
                 [UIColor colorWithRed: 232/255.0 green: 0/255.0 blue: 6/255.0 alpha: 1.0],
             TREND_FALL_COLOR_KEY:
                 [UIColor colorWithRed: 65/255.0 green: 255/255.0 blue: 173/255.0 alpha: 1.0],
             TREND_CURRENT_LINE_COLOR_KEY:
                 [UIColor colorWithRed: 115.0/255.0 green: 186/255.0 blue: 243/255.0 alpha: 1.0],
             TREND_AVERGE_LINE_COLOR_KEY:
                 [UIColor blueColor],
             TREDN_FILL_COLOR_KEY:
                 [UIColor colorWithRed: 115.0/255.0 green: 186/255.0 blue: 243/255.0 alpha: 0.2],
             TREND_VOLUME_COLOR: [UIColor colorWithRed: 255.0/255.0 green: 106/255.0 blue: 45/255.0 alpha: 0.2],
             TREND_SCALES_COLOR: [UIColor colorWithRed: 153/255.0 green: 153/255.0 blue: 153/255.0 alpha: 1.0]
             };
}

+ (NSDictionary *)klineStyleDict
{
    return @{
//             CHAR_BOUND_COLOR_KEY: [UIColor colorWithRed: 204.0/255.0 green:204.0/255.0 blue:204.0/255.0 alpha: 1.0],
             CHAR_BOUND_COLOR_KEY:[UIColor colorWithString:@"1C262F"],
             FOCUS_LINE_COLOR_KEY: [UIColor blueColor],
             FOCUS_BACK_COLOR_KEY: [UIColor grayColor],
             FOCUS_TEXT_COLOR_KEY: [UIColor colorWithString:@"999999"],
             FOCUS_SEGMENT_LINE_COLOR_KEY:[UIColor colorWithString:@"E0E0E0"],
             
             KLINE_RISE_COLOR_KEY:
                 [UIColor colorWithRed: 232/255.0 green: 0/255.0 blue: 63/255.0 alpha: 1.0],
             KLINE_FALL_COLOR_KEY:
                 [UIColor colorWithRed: 65/255.0 green: 255/255.0 blue: 173/255.0 alpha: 1.0],
             KLINE_AVERGE1_COLOR_KEY:
                 [UIColor colorWithRed: 217/255.0 green: 49/255.0 blue: 49/255.0 alpha: 1.0],
             KLINE_AVERGE2_COLOR_KEY:
                 [UIColor colorWithRed: 130/255.0 green: 19/255.0 blue: 17/255.0 alpha: 1.0],
             KLINE_AVERGE3_COLOR_KEY:
                 [UIColor colorWithRed: 255/255.0 green: 159/255.0 blue: 39/255.0 alpha: 1.0],
             KLINE_AVERGE4_COLOR_KEY:
                 [UIColor colorWithRed: 1/255.0 green: 119/255.0 blue: 218/255.0 alpha: 1.0],
             
             };
}

+ (UIColor *)riseColor
{
    return [UIColor colorWithRed: 232/255.0 green: 0/255.0 blue: 6/255.0 alpha: 1.];
}

+ (UIColor *)stableColor
{
    return [UIColor colorWithRed: 153/255.0 green: 153/255.0 blue: 153/255.0 alpha: 1.];
}

+ (UIColor *)fallColor
{
    return [UIColor colorWithRed: 65/255.0 green: 255/255.0 blue: 173/255.0 alpha: 1.];
    
}

+ (UIColor *)colorForPrice: (double)price basic: (double)basic
{
    if (price > basic) {
        return  [self riseColor];
    }
    else if (price == basic)
    {
        return [self stableColor];
    }
    else
    {
        return [self fallColor];
    }
}

+ (UIColor *)borderColor
{
    return [UIColor colorWithRed: 204/255.0 green: 204/255.0 blue: 204/255.0 alpha: 1.];
}

+ (UIColor *)backgroundColorOfRise
{
    return [self riseColor];
}

+ (UIColor *)backgroundColorOfFall
{
    return [self fallColor];
}

+ (UIColor *)backgroundColorOfStable
{
    return [self stableColor];
}

+ (NSString *)signedStringOfPrice: (double)price
{
    return [NSString stringWithFormat: @"%+.2f", price];
}

+ (NSString *)signedStringOfPercentage: (double)value
{
    return [NSString stringWithFormat: @"%+.2f%%", value*100];
}

+ (NSString *)formatPrice: (double)price
{
    return [NSString stringWithFormat: @"%.2lf", price];
}

+ (NSString *)formatNumberValue: (double)value
{
    if (value > 1000000000000) {
        return [NSString stringWithFormat: @"%.2lf万亿", value/1000000000000];
    }
    else if (value > 100000000) {
        return [NSString stringWithFormat: @"%.2lf亿", value/100000000];
    }
    else if (value > 10000) {
        return [NSString stringWithFormat: @"%.2lf万", value/10000];
    }
    else
    {
        return [NSString stringWithFormat: @"%.0lf", value];
    }
}

+ (NSString *)formatVolumeHand: (double)value
{
    value = value /100.0;
    if (value > 1000000000000) {
        return [NSString stringWithFormat: @"%.2lf万亿手", value/1000000000000];
    }
    else if (value > 100000000) {
        return [NSString stringWithFormat: @"%.2lf亿手", value/100000000];
    }
    else if (value > 10000) {
        return [NSString stringWithFormat: @"%.2lf万手", value/10000];
    }
    else
    {
        return [NSString stringWithFormat: @"%.0lf手", value];
    }
}

+ (NSString *)formatVolumeValue: (double)value
{
    value = value /100.0;
    if (value > 1000000000000) {
        return [NSString stringWithFormat: @"%.2lf万亿", value/1000000000000];
    }
    else if (value > 100000000) {
        return [NSString stringWithFormat: @"%.2lf亿", value/100000000];
    }
    else if (value > 10000) {
        return [NSString stringWithFormat: @"%.2lf万", value/10000];
    }
    else
    {
        return [NSString stringWithFormat: @"%.0lf", value];
    }
}

@end
